import 'package:factoryside/bean/policy_entity.dart';

policyEntityFromJson(PolicyEntity data, Map<String, dynamic> json) {
	if (json['StatusCode'] != null) {
		data.statusCode = json['StatusCode'] is String
				? int.tryParse(json['StatusCode'])
				: json['StatusCode'].toInt();
	}
	if (json['Info'] != null) {
		data.info = json['Info'].toString();
	}
	if (json['Count'] != null) {
		data.count = json['Count'] is String
				? int.tryParse(json['Count'])
				: json['Count'].toInt();
	}
	if (json['Data'] != null) {
		data.data = new PolicyData().fromJson(json['Data']);
	}
	return data;
}

Map<String, dynamic> policyEntityToJson(PolicyEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['StatusCode'] = entity.statusCode;
	data['Info'] = entity.info;
	data['Count'] = entity.count;
	if (entity.data != null) {
		data['Data'] = entity.data.toJson();
	}
	return data;
}

policyDataFromJson(PolicyData data, Map<String, dynamic> json) {
	if (json['accessid'] != null) {
		data.accessid = json['accessid'].toString();
	}
	if (json['policy'] != null) {
		data.policy = json['policy'].toString();
	}
	if (json['signature'] != null) {
		data.signature = json['signature'].toString();
	}
	if (json['dir'] != null) {
		data.dir = json['dir'].toString();
	}
	if (json['host'] != null) {
		data.host = json['host'].toString();
	}
	if (json['expire'] != null) {
		data.expire = json['expire'].toString();
	}
	if (json['callback'] != null) {
		data.callback = json['callback'].toString();
	}
	if (json['fileName'] != null) {
		data.fileName = json['fileName'].toString();
	}
	return data;
}

Map<String, dynamic> policyDataToJson(PolicyData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['accessid'] = entity.accessid;
	data['policy'] = entity.policy;
	data['signature'] = entity.signature;
	data['dir'] = entity.dir;
	data['host'] = entity.host;
	data['expire'] = entity.expire;
	data['callback'] = entity.callback;
	data['fileName'] = entity.fileName;
	return data;
}